$this_path = Split-Path -Parent ($MyInvocation.MyCommand.Definition) # get the directory of this running script
#<---------------------- initilize excel com application
Try{ # the script will quit if no excel has been installed in the running computer
	$excel = new-object -comobject excel.application ; # $excel.Visible=$true
}Catch{
    [void][System.Windows.Forms.MessageBox]::Show($_, 'Excel Running Error', 'OK', 'Error');return
}Finally{}
#<-------------------------------------------------- enable macro running
$macro_key="HKCU\Software\Microsoft\Office\$($excel.Version)\excel\Security"
reg delete $macro_key /v AccessVBOM /f 1>$null 2>&1
reg delete $macro_key /v VBAWarnings /f 1>$null 2>&1
#<--------------------------------------------------open excel and start to combine csv files
$excel.DisplayAlerts=$false # disable warning popup when makeing changes
$excel.workbooks.open("$this_path\config\Inventory.xlsb") 1>$null
$excel.Run("MergeVDIList")
#<-------------------------------------------------- completely quit and remove excel com-object
$excel.quit() ; [System.Runtime.Interopservices.Marshal]::ReleaseComObject($excel) 1>$null ; Remove-Variable excel
(cat "$this_path\config\inventory.txt").replace('"',"") |out-file "$this_path\config\inventory.txt" -Encoding utf8 -Force